import flask
from mowang.mowang_all_item import MowangAllItems, AllVersionInfo

mowang_download = flask.Blueprint("mowang_download", __name__)

allInfos = AllVersionInfo()

@mowang_download.route("/mowang/ipas/", methods=["get"])
def get_ipas_list():
    allInfos.mimi_more_url = flask.request.host_url + flask.url_for("mowang_download.get_ipas_more", name="mimi")
    allInfos.luka_more_url = flask.request.host_url + flask.url_for("mowang_download.get_ipas_more", name="luka")
    allInfos.miyo_more_url = flask.request.host_url + flask.url_for("mowang_download.get_ipas_more", name="miyo")
    allInfos.mw_more_url = flask.request.host_url + flask.url_for("mowang_download.get_ipas_more", name="mostone")

    infos = {
        "allInfos": allInfos,
        "ismore": False
    }
    return flask.render_template("mowang_all_item.html", infos=infos)

@mowang_download.route("/mowang/ipas/more/")
@mowang_download.route("/mowang/ipas/more/<name>")
def get_ipas_more(name=None):
    versions = []
    if name is None:
        name = "miyo"
    if name == "miyo":
        versions = allInfos.miyo
    elif name == "luka":
        versions = allInfos.luka
    elif name == "mimi":
        versions = allInfos.mimi
    elif name == "mostone":
        versions = allInfos.mw
    else:
        pass
    infos = {
        "ismore": True,
        "versions": versions
    }
    return flask.render_template("mowang_all_item.html", infos=infos)
